package controller;

import entity.Book;
import service.BookService;
import service.impl.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http

        .HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
public class IndexServlet extends HttpServlet {
    private BookService bookService = new BookServiceImpl();
    public IndexServlet(HttpServletRequest request, HttpServletResponse response ) throws SQLException, ClassNotFoundException, ServletException, IOException {
       String pageStr=request.getParameter("page");
       Integer page=Integer.parseInt(pageStr);
       List<Book> list=bookService.findAll();
       request.setAttribute("list",list);
       request.getRequestDispatcher("index.jsp").forward(request,response);
    }

}